package com.example.xm.presenter.discover;

import com.example.xm.base.BasePresenter;
import com.example.xm.bean.DiscoverBean.DiscoverPagerBean;
import com.example.xm.bean.DiscoverBean.DiscoverPaoZhiBean;
import com.example.xm.bean.DiscoverBean.DiscoverReMenBean;
import com.example.xm.bean.HomeBean.HomeRewardBean;
import com.example.xm.common.CommonSubScriBer;
import com.example.xm.interfaces.discover.IDiscover;
import com.example.xm.model.HttpManager;
import com.example.xm.utiles.RxUtils;

public class DiscoverPresenter extends BasePresenter<IDiscover.View> implements IDiscover.Presenter {

    @Override
    public void getReMen() {
        addSubscribe(HttpManager
                .getInstance()
                .getDiscoverApi()
                .getReMen()
                .compose(RxUtils.<DiscoverReMenBean>rxScheduler())
                .subscribeWith(new CommonSubScriBer<DiscoverReMenBean>(mView) {
                    @Override
                    public void onNext(DiscoverReMenBean discoverReMenBean) {
                        mView.getReMenResult(discoverReMenBean);
                    }
                }));
    }

    @Override
    public void getPaoZhi() {
        addSubscribe(HttpManager
                .getInstance()
                .getDiscoverApi()
                .getPaoZhi()
                .compose(RxUtils.<DiscoverPaoZhiBean>rxScheduler())
                .subscribeWith(new CommonSubScriBer<DiscoverPaoZhiBean>(mView) {
                    @Override
                    public void onNext(DiscoverPaoZhiBean paoZhiBean) {
                        mView.getPaoZhiResult(paoZhiBean);
                    }
                }));
    }

    @Override
    public void getPager(int type) {
        addSubscribe(HttpManager
                .getInstance()
                .getDiscoverApi()
                .getPager(type)
                .compose(RxUtils.<DiscoverPagerBean>rxScheduler())
                .subscribeWith(new CommonSubScriBer<DiscoverPagerBean>(mView) {
                    @Override
                    public void onNext(DiscoverPagerBean pagerBean) {
                        mView.getPagerResult(pagerBean);
                    }
                }));
    }
}
